package com.boc.ewr.util.file.enumeration;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.Optional;

/**
 * 企业运营状态（登记状态）
 */
@Slf4j
public enum CompanyStatusEnum {

    OPENING1("01", "存续（在营、开业、在册）"),
    OPENING2("02", "正常"),
    OPENING3("03", "存续"),
    OPENING4("04", "在营（开业）"),
    OPENING5("05", "正常执业"),
    OPENING6("11", "在营（开业）企业"),
    OPENING7("12", "存续(在营、开业、在册)"),
    OPENING8("13", "开业"),
    SHUT1("14", "撤销"),
    BLANK("15", "-"),
    SHUT2("16", "歇业"),
    SHUT3("17", "迁出"),
    SHUT4("51", "注销"),
    SHUT5("52", "吊销"),
    OPENING9("61", "未注销"),
    OPENING10("62", "未吊销"),
    OPENING11("63", "在业"),
    SHUT6("71", "已注销"),
    SHUT8("73", "吊销，未注销"),
    SHUT9("74", "吊销，已注销"),
    SHUT7("72", "已吊销");


    private String index;
    private String value;

    CompanyStatusEnum(String index, String value){

        this.index = index;
        this.value = value;
    }

    /**
     * 根据value获取枚举对象
     *
     * @param val
     * @return
     */
    public static CompanyStatusEnum getIndexByValue(String val) {
        Optional<CompanyStatusEnum> first = Arrays.stream(CompanyStatusEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        CompanyStatusEnum expEnum = first.orElse(null);
        log.info("选择的枚举类型是：" + expEnum.toString());
        return expEnum;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
